﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<CognisessDA.User>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script language="javascript" type="text/javascript">
        $.validator.addMethod('selectNone',
             function(value, element) {
                 return this.optional(element) || (value != 0);
             },
             "Please select an option.");
             
        function clientVerfiy() {
            $("#formMain").validate({
                rules: {
                    Username: { required: true, rangelength: [6, 12] },
                    Password: { required: true },
                    Email: { email: true },
                    EducationLevel: { selectNone: true },
                    TimeZone: { selectNone: true },
                    HowToKnowUs: { selectNone: true }
                },

                messages: {
                    Username: { required: "Please enter your User Name.", rangelength: "UserName must be in 6-12 between characters." },
                    Password: { required: "Please enter your Password." },
                    Email: { email: "Please enter a valid email address." }
                }

            });
            $(".field-validation-error").remove();
        }

        $(function() {
            $('#BirthDate').datepicker({ duration: '', showTime: true, constrainInput: true });
        });
    </script>

    <style type="text/css">
        input[class="error"]
        {
            border: 1px solid #ff0000;
            background-color: #ffeeee;
        }
        Label[class="error"]
        {
            padding-left: 10px;
        }
    </style>
    <% using (Html.BeginForm("Create", "UserMaster", FormMethod.Post, new { id = "formMain" }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <fieldset>
        <legend>Create New User</legend>
        <div class="editor-label">
            <label for="Username">
                User Name</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Username)%>
            <%= Html.ValidationMessageFor(model => model.Username)%>
        </div>
        <div class="editor-label">
            <label for="Username">
                Password</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Password)%>
            <%= Html.ValidationMessageFor(model => model.Password)%>
        </div>
        <div class="editor-label">
            <label for="Username">
                First Name</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Firstname)%>
            <%= Html.ValidationMessageFor(model => model.Firstname)%>
        </div>
        <div class="editor-label">
            <label for="Username">
                Last Name</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Lastname)%>
            <%= Html.ValidationMessageFor(model => model.Lastname)%>
        </div>
        <div class="editor-label">
            <label for="Username">
                Avater</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Avater)%>
            <%= Html.ValidationMessageFor(model => model.Avater)%>
        </div>
        <div class="editor-label">
            <label for="AboutMe">
                AboutMe</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.AboutMe)%>
            <%= Html.ValidationMessageFor(model => model.AboutMe)%>
        </div>
        <div class="editor-label">
            <label for="Email">
                Email</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Email)%>
            <%= Html.ValidationMessageFor(model => model.Email)%>
        </div>
        <%--        <div class="editor-label">
            <%= Html.LabelFor(model => model.OrgId) %>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.OrgId) %>
            <%= Html.ValidationMessageFor(model => model.OrgId) %>
        </div>
        <div class="editor-label">
            <%= Html.LabelFor(model => model.LoginNum) %>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.LoginNum) %>
            <%= Html.ValidationMessageFor(model => model.LoginNum) %>
        </div>
        <div class="editor-label">
            <label for="LastLogin">
                Last Login Time</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.LastLogin)%>
            <%= Html.ValidationMessageFor(model => model.LastLogin)%>
        </div>
        <div class="editor-label">
            <label for="LastLogin">
                Create Time</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.CreateTime)%>
            <%= Html.ValidationMessageFor(model => model.CreateTime)%>
        </div>--%>
        <div class="editor-label">
            <label for="LastLogin">
                Birth Date</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.BirthDate)%>
            <%= Html.ValidationMessageFor(model => model.BirthDate)%>
        </div>
        <div class="editor-label">
            <label for="Gender">
                Gender</label>
        </div>
        <div class="editor-field">
            <%=Html.RadioButtonFor(m => m.Gender, (int)CognisessCommLib.EnumGender.Male, new { @checked = "check"})%>Male
            <%=Html.RadioButtonFor(m => m.Gender, (int)CognisessCommLib.EnumGender.Female)%>Female
        </div>
        <div class="editor-label">
            <label for="EducationLevel">
                Education Level</label>
        </div>
        <div class="editor-field">
            <%= Html.DropDownListFor(model => model.EducationLevel, (IEnumerable<SelectListItem>)ViewData["Education"])%>
        </div>
        <div class="editor-label">
            <label for="IsMarried">
                Is Married</label>
        </div>
        <div class="editor-field">
            <%=Html.RadioButtonFor(m => m.IsMarried, (int)CognisessCommLib.EnumIsMarried.Married, new { @checked = "check" })%>Married
            <%=Html.RadioButtonFor(m => m.IsMarried, (int)CognisessCommLib.EnumIsMarried.Unmarried)%>Unmarried
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Occupation</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Occupation)%>
            <%= Html.ValidationMessageFor(model => model.Occupation)%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Industry</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Industry)%>
            <%= Html.ValidationMessageFor(model => model.Industry)%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                How To Know Us</label>
        </div>
        <div class="editor-field">
            <%= Html.DropDownListFor(model => model.HowToKnowUs, (IEnumerable<SelectListItem>)ViewData["About"])%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Time Zone</label>
        </div>
        <div class="editor-field">
            <%= Html.DropDownListFor(model => model.TimeZone, (IEnumerable<SelectListItem>)ViewData["TimeZoneT"])%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Address</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Address)%>
            <%= Html.ValidationMessageFor(model => model.Address)%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Is Trial</label>
        </div>
        <div class="editor-field">
            <%=Html.RadioButtonFor(m => m.IsTrial, (int)CognisessCommLib.EnumIsTrial.Trial, new { @checked = "check" })%>Trial
            <%=Html.RadioButtonFor(m => m.IsTrial, (int)CognisessCommLib.EnumIsTrial.OutOfTrial)%>Out
            Of Trial
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Remaining Day</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.RemainingDay)%>
            <%= Html.ValidationMessageFor(model => model.RemainingDay)%>
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Is Activated</label>
        </div>
        <div class="editor-field">
            <%=Html.RadioButtonFor(m => m.IsActivated, (int)CognisessCommLib.EnumIsActivated.Activated, new { @checked = "check" })%>Activated
            <%=Html.RadioButtonFor(m => m.IsActivated, (int)CognisessCommLib.EnumIsActivated.Unctivated)%>Unctivated
        </div>
        <div class="editor-label">
            <label for="Occupation">
                Telephone</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Telephone)%>
            <%= Html.ValidationMessageFor(model => model.Telephone)%>
        </div>
        <div class="editor-label">
            <label>
                Fax</label>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Fax)%>
            <%= Html.ValidationMessageFor(model => model.Fax)%>
        </div>
        <p>
            <input type="submit" value="Create" onclick="clientVerfiy();" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%= Html.ActionLink("Back to List", "Index")%>
    </div>
</asp:Content>
